/*     */ package com.zimbra.cs.client.soap;
/*     */ 
/*     */ import com.zimbra.common.service.ServiceException;
/*     */ import com.zimbra.common.soap.SoapFaultException;
/*     */ import com.zimbra.common.util.CliUtil;
/*     */ import com.zimbra.cs.client.LmcBrowseData;
/*     */ import com.zimbra.cs.client.LmcContact;
/*     */ import com.zimbra.cs.client.LmcContactAttr;
/*     */ import com.zimbra.cs.client.LmcConversation;
/*     */ import com.zimbra.cs.client.LmcEmailAddress;
/*     */ import com.zimbra.cs.client.LmcFolder;
/*     */ import com.zimbra.cs.client.LmcMessage;
/*     */ import com.zimbra.cs.client.LmcMimePart;
/*     */ import com.zimbra.cs.client.LmcNote;
/*     */ import com.zimbra.cs.client.LmcSession;
/*     */ import com.zimbra.cs.client.LmcTag;
/*     */ import com.zimbra.cs.mailbox.MailItem.Type;
/*     */ import java.io.File;
/*     */ import java.io.IOException;
/*     */ import java.io.PrintStream;
/*     */ import java.util.Date;
/*     */ import java.util.HashMap;
/*     */ import java.util.Iterator;
/*     */ import java.util.List;
/*     */ import java.util.Map.Entry;
/*     */ import java.util.Set;
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ public class Tester
/*     */ {
/*     */   private static String trashFolderID;
/*     */   private static String inboxFolderID;
/*     */   private static String cvsConvID;
/*     */   private static final String FOLDER_NAME_TRASH = "Trash";
/*     */   private static final String FOLDER_NAME_INBOX = "INBOX";
/*  42 */   private static LmcEmailAddress gEa = new LmcEmailAddress();
/*  43 */   static { gEa.setType("t");
/*  44 */     gEa.setContent("kluge@yahoo.com");
/*  45 */     gEa.setEmailAddress("kluge@yahoo.com");
/*     */   }
/*     */   
/*     */   private static void recursiveDumpFolder(LmcFolder f, int depth)
/*     */   {
/*  50 */     for (int j = 0; j < depth; j++)
/*  51 */       System.out.print("\t");
/*  52 */     System.out.println(f);
/*  53 */     String fName = f.getName();
/*  54 */     if (fName != null)
/*  55 */       if (fName.equals("Trash")) {
/*  56 */         trashFolderID = f.getFolderID();
/*  57 */       } else if (fName.equals("INBOX"))
/*  58 */         inboxFolderID = f.getFolderID();
/*  59 */     LmcFolder[] subFolders = f.getSubFolders();
/*  60 */     for (int i = 0; (subFolders != null) && (i < subFolders.length); i++) {
/*  61 */       recursiveDumpFolder(subFolders[i], depth + 1);
/*     */     }
/*     */   }
/*     */   
/*     */   private static void doSearchReadDelete(LmcSession session, String serverURL) throws IOException, LmcSoapClientException, ServiceException, SoapFaultException
/*     */   {
/*  67 */     System.out.println("==== SEARCH \"CVS\" ======");
/*  68 */     LmcSearchRequest sReq = new LmcSearchRequest();
/*  69 */     sReq.setOffset("0");
/*  70 */     sReq.setLimit("30");
/*  71 */     sReq.setQuery("Subject:\"CVS COMMIT\"");
/*  72 */     sReq.setTypes(MailItem.Type.MESSAGE.toString());
/*  73 */     sReq.setSession(session);
/*  74 */     LmcSearchResponse sResp = (LmcSearchResponse)sReq.invoke(serverURL);
/*     */     
/*     */ 
/*  77 */     List mList = sResp.getResults();
/*  78 */     LmcMessage msg = null;
/*  79 */     for (Iterator mit = mList.iterator(); mit.hasNext();) {
/*  80 */       msg = (LmcMessage)mit.next();
/*  81 */       System.out.println(msg);
/*     */     }
/*     */     
/*     */ 
/*     */ 
/*  86 */     String msgID = null;
/*  87 */     if (mList.isEmpty()) {
/*  88 */       throw new LmcSoapClientException("test mailbox probably not set up properly");
/*     */     }
/*  90 */     msgID = msg.getID();
/*     */     
/*     */ 
/*  93 */     System.out.println("reading message " + msgID);
/*  94 */     LmcGetMsgRequest gmReq = new LmcGetMsgRequest();
/*  95 */     gmReq.setMsgToGet(msgID);
/*  96 */     gmReq.setRead("1");
/*  97 */     gmReq.setSession(session);
/*  98 */     LmcGetMsgResponse gmResp = (LmcGetMsgResponse)gmReq.invoke(serverURL);
/*     */     
/*     */ 
/* 101 */     System.out.println("move to trash message " + msgID);
/* 102 */     LmcMsgActionRequest maReq = new LmcMsgActionRequest();
/* 103 */     maReq.setMsgList(msgID);
/* 104 */     maReq.setOp("move");
/* 105 */     maReq.setFolder(trashFolderID);
/* 106 */     maReq.setSession(session);
/* 107 */     LmcMsgActionResponse maResp = (LmcMsgActionResponse)maReq.invoke(serverURL);
/*     */     
/*     */ 
/* 110 */     System.out.println("hard delete message " + msgID);
/* 111 */     maReq.setOp("delete");
/* 112 */     maReq.setFolder(null);
/* 113 */     maResp = (LmcMsgActionResponse)maReq.invoke(serverURL);
/*     */   }
/*     */   
/*     */   private static void doCreateDeleteFolder(LmcSession session, String serverURL)
/*     */     throws IOException, LmcSoapClientException, ServiceException, SoapFaultException
/*     */   {
/* 119 */     System.out.println("==== CREATE FOLDER ======");
/* 120 */     LmcCreateFolderRequest cfReq = new LmcCreateFolderRequest();
/* 121 */     cfReq.setSession(session);
/* 122 */     cfReq.setName("testfolder");
/* 123 */     cfReq.setParentID(inboxFolderID);
/* 124 */     LmcCreateFolderResponse cfResp = (LmcCreateFolderResponse)cfReq.invoke(serverURL);
/* 125 */     String newID = cfResp.getFolder().getFolderID();
/* 126 */     System.out.println("created new folder with ID " + newID);
/*     */     
/*     */ 
/* 129 */     System.out.println("==== DELETE FOLDER ======");
/* 130 */     LmcFolderActionRequest faReq = new LmcFolderActionRequest();
/* 131 */     faReq.setSession(session);
/* 132 */     faReq.setFolderList(newID);
/* 133 */     faReq.setOp("delete");
/* 134 */     LmcFolderActionResponse faResp = (LmcFolderActionResponse)faReq.invoke(serverURL);
/* 135 */     System.out.println("delete folder successful");
/*     */   }
/*     */   
/*     */   private static void doSearchAndConvAction(LmcSession session, String serverURL)
/*     */     throws IOException, LmcSoapClientException, ServiceException, SoapFaultException
/*     */   {
/* 141 */     System.out.println("==== SEARCH \"CVS\" ======");
/* 142 */     LmcSearchRequest sReq = new LmcSearchRequest();
/* 143 */     sReq.setOffset("0");
/* 144 */     sReq.setLimit("30");
/* 145 */     sReq.setQuery("Subject:\"CVS COMMIT\"");
/* 146 */     sReq.setTypes(MailItem.Type.CONVERSATION.toString());
/* 147 */     sReq.setSession(session);
/* 148 */     LmcSearchResponse sResp = (LmcSearchResponse)sReq.invoke(serverURL);
/*     */     
/* 150 */     LmcConversation conv = null;
/* 151 */     LmcConversation firstConv = null;
/* 152 */     List cList = sResp.getResults();
/* 153 */     for (Iterator cit = cList.iterator(); cit.hasNext();) {
/* 154 */       conv = (LmcConversation)cit.next();
/* 155 */       if (firstConv == null)
/* 156 */         firstConv = conv;
/* 157 */       System.out.println(conv);
/*     */     }
/*     */     
/*     */ 
/*     */ 
/* 162 */     if (cList.isEmpty()) {
/* 163 */       throw new LmcSoapClientException("test mailbox probably not set up properly");
/*     */     }
/* 165 */     cvsConvID = conv.getID();
/*     */     
/*     */ 
/*     */ 
/*     */ 
/* 170 */     System.out.println("move to trash conv " + cvsConvID);
/* 171 */     LmcConvActionRequest caReq = new LmcConvActionRequest();
/* 172 */     caReq.setConvList(cvsConvID);
/* 173 */     caReq.setOp("move");
/* 174 */     caReq.setFolder(trashFolderID);
/* 175 */     caReq.setSession(session);
/* 176 */     LmcConvActionResponse caResp = (LmcConvActionResponse)caReq.invoke(serverURL);
/*     */     
/*     */ 
/* 179 */     System.out.println("move to INBOX conv " + cvsConvID);
/* 180 */     caReq.setConvList(cvsConvID);
/* 181 */     caReq.setOp("move");
/* 182 */     caReq.setFolder(inboxFolderID);
/* 183 */     caReq.setSession(session);
/* 184 */     caResp = (LmcConvActionResponse)caReq.invoke(serverURL);
/*     */   }
/*     */   
/*     */ 
/*     */   private static void getAndDumpContacts(LmcSession session, String serverURL)
/*     */     throws IOException, LmcSoapClientException, ServiceException, SoapFaultException
/*     */   {
/* 191 */     System.out.println("==== GET CONTACTS ======");
/* 192 */     LmcGetContactsRequest gcReq = new LmcGetContactsRequest();
/* 193 */     gcReq.setSession(session);
/* 194 */     LmcGetContactsResponse gcResp = (LmcGetContactsResponse)gcReq.invoke(serverURL);
/*     */     
/*     */ 
/* 197 */     System.out.println("====== DUMP CONTACTS ======");
/* 198 */     LmcContact[] contacts = gcResp.getContacts();
/* 199 */     for (int o = 0; (contacts != null) && (o < contacts.length); o++) {
/* 200 */       System.out.println(contacts[o]);
/*     */     }
/*     */   }
/*     */   
/*     */   private static void doSearchConv(LmcSession session, String serverURL)
/*     */     throws IOException, LmcSoapClientException, ServiceException, SoapFaultException
/*     */   {
/* 207 */     System.out.println("==== SEARCH CONV ======");
/* 208 */     LmcSearchConvRequest sReq = new LmcSearchConvRequest();
/* 209 */     sReq.setOffset("0");
/* 210 */     sReq.setLimit("30");
/* 211 */     sReq.setTypes(MailItem.Type.MESSAGE.toString());
/* 212 */     sReq.setQuery("CVS");
/* 213 */     sReq.setSession(session);
/* 214 */     sReq.setConvID(cvsConvID);
/* 215 */     LmcSearchConvResponse sResp = (LmcSearchConvResponse)sReq.invoke(serverURL);
/*     */     
/*     */ 
/* 218 */     List mList = sResp.getResults();
/* 219 */     LmcMessage msg = null;
/* 220 */     for (Iterator mit = mList.iterator(); mit.hasNext();) {
/* 221 */       msg = (LmcMessage)mit.next();
/* 222 */       System.out.println(msg);
/*     */     }
/*     */   }
/*     */   
/*     */   private static void doBrowse(LmcSession session, String serverURL) throws IOException, LmcSoapClientException, ServiceException, SoapFaultException
/*     */   {
/* 228 */     System.out.println("======= BROWSE BY DOMAIN ======");
/* 229 */     LmcBrowseRequest bReq = new LmcBrowseRequest();
/* 230 */     bReq.setBrowseBy("domains");
/* 231 */     bReq.setSession(session);
/* 232 */     LmcBrowseResponse bResp = (LmcBrowseResponse)bReq.invoke(serverURL);
/* 233 */     System.out.println("got back browse data");
/* 234 */     LmcBrowseData[] bd = bResp.getData();
/* 235 */     for (int i = 0; i < bd.length; i++) {
/* 236 */       System.out.println(bd[i].getFlags() + " " + bd[i].getData());
/*     */     }
/*     */   }
/*     */   
/*     */ 
/*     */ 
/*     */   private static void doCreateDeleteContact(LmcSession session, String serverURL)
/*     */     throws IOException, LmcSoapClientException, ServiceException, SoapFaultException
/*     */   {
/* 245 */     System.out.println("=========== CREATING CONTACT ============");
/* 246 */     LmcCreateContactRequest ccReq = new LmcCreateContactRequest();
/* 247 */     ccReq.setSession(session);
/* 248 */     LmcContact c = new LmcContact();
/* 249 */     LmcContactAttr[] attrs = { new LmcContactAttr("email", "1", null, "schumie@f1.com"), new LmcContactAttr("firstName", "2", null, "Michael"), new LmcContactAttr("lastName", "3", null, "Schumacher") };
/*     */     
/*     */ 
/*     */ 
/*     */ 
/* 254 */     c.setAttrs(attrs);
/* 255 */     ccReq.setContact(c);
/* 256 */     LmcCreateContactResponse ccResp = (LmcCreateContactResponse)ccReq.invoke(serverURL);
/* 257 */     String newID = ccResp.getContact().getID();
/*     */     
/*     */ 
/* 260 */     getAndDumpContacts(session, serverURL);
/*     */     
/*     */ 
/* 263 */     System.out.println("=========== DELETING CONTACT ============");
/* 264 */     LmcContactActionRequest caReq = new LmcContactActionRequest();
/* 265 */     caReq.setSession(session);
/* 266 */     caReq.setOp("delete");
/* 267 */     caReq.setIDList(newID);
/* 268 */     LmcContactActionResponse caResp = (LmcContactActionResponse)caReq.invoke(serverURL);
/*     */     
/*     */ 
/*     */ 
/* 272 */     getAndDumpContacts(session, serverURL);
/*     */   }
/*     */   
/*     */ 
/*     */   private static void doCreateDeleteTag(LmcSession session, String serverURL)
/*     */     throws IOException, LmcSoapClientException, ServiceException, SoapFaultException
/*     */   {
/* 279 */     System.out.println("=========== CREATING TAG ============");
/* 280 */     LmcCreateTagRequest ctReq = new LmcCreateTagRequest();
/* 281 */     ctReq.setSession(session);
/* 282 */     ctReq.setName("testtag3");
/* 283 */     ctReq.setColor("0");
/* 284 */     LmcCreateTagResponse ctResp = (LmcCreateTagResponse)ctReq.invoke(serverURL);
/* 285 */     LmcTag newTag = ctResp.getTag();
/* 286 */     System.out.println("created tag " + newTag.getID());
/*     */     
/*     */ 
/* 289 */     System.out.println("=========== DELETING TAG ============");
/* 290 */     LmcTagActionRequest taReq = new LmcTagActionRequest();
/* 291 */     taReq.setSession(session);
/* 292 */     taReq.setOp("delete");
/* 293 */     taReq.setTagList(newTag.getID());
/* 294 */     LmcTagActionResponse taResp = (LmcTagActionResponse)taReq.invoke(serverURL);
/*     */   }
/*     */   
/*     */   private static void doCreateGetDeleteNote(LmcSession session, String serverURL)
/*     */     throws IOException, LmcSoapClientException, ServiceException, SoapFaultException
/*     */   {
/* 300 */     System.out.println("=========== CREATING NOTE ============");
/* 301 */     LmcCreateNoteRequest ctReq = new LmcCreateNoteRequest();
/* 302 */     ctReq.setSession(session);
/* 303 */     ctReq.setParentID(inboxFolderID);
/* 304 */     ctReq.setContent("this is a test note");
/* 305 */     ctReq.setColor("0");
/* 306 */     LmcCreateNoteResponse ctResp = (LmcCreateNoteResponse)ctReq.invoke(serverURL);
/* 307 */     LmcNote newNote = ctResp.getNote();
/* 308 */     String noteID = newNote.getID();
/* 309 */     System.out.println("created Note " + noteID);
/*     */     
/*     */ 
/* 312 */     System.out.println("=========== GET NOTE ============");
/* 313 */     LmcGetNoteRequest gnReq = new LmcGetNoteRequest();
/* 314 */     gnReq.setSession(session);
/* 315 */     gnReq.setNoteToGet(noteID);
/* 316 */     LmcGetNoteResponse gnResp = (LmcGetNoteResponse)gnReq.invoke(serverURL);
/* 317 */     newNote = gnResp.getNote();
/* 318 */     System.out.println("created Note\n" + newNote);
/*     */     
/*     */ 
/* 321 */     System.out.println("=========== DELETING NOTE ============");
/* 322 */     LmcNoteActionRequest taReq = new LmcNoteActionRequest();
/* 323 */     taReq.setSession(session);
/* 324 */     taReq.setOp("delete");
/* 325 */     taReq.setNoteList(noteID);
/* 326 */     LmcNoteActionResponse taResp = (LmcNoteActionResponse)taReq.invoke(serverURL);
/* 327 */     System.out.println("successfully deleted note " + taResp.getNoteList());
/*     */   }
/*     */   
/*     */   private static void dumpPrefs(HashMap prefMap) {
/* 331 */     System.out.println("===== DUMP THE PREFS ===== ");
/* 332 */     Set s = prefMap.entrySet();
/* 333 */     Iterator i = s.iterator();
/* 334 */     while (i.hasNext()) {
/* 335 */       Map.Entry entry = (Map.Entry)i.next();
/* 336 */       System.out.println("key " + (String)entry.getKey() + " value " + (String)entry.getValue());
/*     */     }
/*     */   }
/*     */   
/*     */   private static void doGetDumpPrefs(LmcSession session, String serverURL)
/*     */     throws IOException, LmcSoapClientException, ServiceException, SoapFaultException
/*     */   {
/* 343 */     System.out.println("====== GET PREFS ==========");
/* 344 */     String[] prefs = { "zimbraPrefMailSignatureEnabled", "zimbraPrefSaveToSent" };
/*     */     
/* 346 */     LmcGetPrefsRequest prefReq = new LmcGetPrefsRequest();
/* 347 */     prefReq.setSession(session);
/* 348 */     prefReq.setPrefsToGet(prefs);
/* 349 */     LmcGetPrefsResponse prefResp = (LmcGetPrefsResponse)prefReq.invoke(serverURL);
/* 350 */     HashMap prefMap = prefResp.getPrefsMap();
/*     */     
/* 352 */     dumpPrefs(prefMap);
/*     */   }
/*     */   
/*     */   private static void doModifyDumpPrefs(LmcSession session, String serverURL) throws IOException, LmcSoapClientException, ServiceException, SoapFaultException
/*     */   {
/* 357 */     System.out.println("=========== MODIFY PREFS ==========");
/* 358 */     HashMap prefMods = new HashMap();
/* 359 */     prefMods.put("zimbraPrefMailSignatureEnabled", "TRUE");
/* 360 */     prefMods.put("zimbraPrefSaveToSent", "TRUE");
/*     */     
/* 362 */     LmcModifyPrefsRequest mpReq = new LmcModifyPrefsRequest();
/* 363 */     mpReq.setSession(session);
/* 364 */     mpReq.setPrefMods(prefMods);
/* 365 */     LmcModifyPrefsResponse mpResp = (LmcModifyPrefsResponse)mpReq.invoke(serverURL);
/*     */     
/* 367 */     doGetDumpPrefs(session, serverURL);
/*     */   }
/*     */   
/*     */   private static void doChangePassword(LmcSession session, String account, String currPassword, String serverURL)
/*     */     throws IOException, LmcSoapClientException, ServiceException, SoapFaultException
/*     */   {
/* 373 */     System.out.println("=========== CHANGE PASSWORD ==========");
/*     */     
/*     */ 
/* 376 */     LmcChangePasswordRequest cpReq = new LmcChangePasswordRequest();
/* 377 */     cpReq.setSession(session);
/* 378 */     cpReq.setAccount(account);
/* 379 */     cpReq.setOldPassword(currPassword);
/* 380 */     cpReq.setPassword("test1234");
/* 381 */     cpReq.invoke(serverURL);
/*     */     
/*     */ 
/* 384 */     System.out.println("changing the password back");
/* 385 */     cpReq.setOldPassword("test1234");
/* 386 */     cpReq.setPassword(currPassword);
/* 387 */     cpReq.invoke(serverURL);
/*     */   }
/*     */   
/*     */   private static void doAddMsg(LmcSession session, String serverURL) throws IOException, LmcSoapClientException, ServiceException, SoapFaultException
/*     */   {
/* 392 */     System.out.println("====== ADD MSG =======");
/*     */     
/* 394 */     LmcMessage lMsg = new LmcMessage();
/* 395 */     lMsg.setEmailAddresses(new LmcEmailAddress[] { gEa });
/* 396 */     Date d = new Date();
/* 397 */     lMsg.setSubject("AddMsg: " + d);
/* 398 */     lMsg.setFolder(inboxFolderID);
/* 399 */     lMsg.setContent("From: kluge@example.zimbra.com\r\nTo: kluge@dogfood.example.zimbra.com\r\nSubject: AddMsg " + d + "\r\n\r\nThis is some text.");
/* 400 */     LmcAddMsgRequest amr = new LmcAddMsgRequest();
/* 401 */     amr.setMsg(lMsg);
/* 402 */     amr.setSession(session);
/* 403 */     LmcAddMsgResponse amrResp = (LmcAddMsgResponse)amr.invoke(serverURL);
/* 404 */     System.out.println("Add successful, resulting ID " + amrResp.getID());
/*     */   }
/*     */   
/*     */   private static void doGetInfo(LmcSession session, String serverURL)
/*     */     throws IOException, LmcSoapClientException, ServiceException, SoapFaultException
/*     */   {
/* 410 */     System.out.println("=========== GET INFO ==========");
/* 411 */     LmcGetInfoRequest giReq = new LmcGetInfoRequest();
/* 412 */     giReq.setSession(session);
/* 413 */     LmcGetInfoResponse giResp = (LmcGetInfoResponse)giReq.invoke(serverURL);
/* 414 */     System.out.println("Account name: " + giResp.getAcctName());
/* 415 */     System.out.println("lifetime: " + giResp.getLifetime());
/* 416 */     dumpPrefs(giResp.getPrefMap());
/*     */   }
/*     */   
/*     */   private static void doSearchGal(LmcSession session, String serverURL, String searchTarget) throws IOException, LmcSoapClientException, ServiceException, SoapFaultException
/*     */   {
/* 421 */     System.out.println("=========== SEARCH GAL ==========");
/* 422 */     LmcSearchGalRequest sgReq = new LmcSearchGalRequest();
/* 423 */     sgReq.setSession(session);
/* 424 */     sgReq.setName(searchTarget);
/* 425 */     LmcSearchGalResponse sgResp = (LmcSearchGalResponse)sgReq.invoke(serverURL);
/* 426 */     System.out.println("Search results ----");
/* 427 */     LmcContact[] contacts = sgResp.getContacts();
/* 428 */     for (int o = 0; (contacts != null) && (o < contacts.length); o++) {
/* 429 */       System.out.println(contacts[o]);
/*     */     }
/*     */   }
/*     */   
/*     */   public static void main(String[] argv) {
/*     */     
/* 435 */     if (argv.length != 3) {
/* 436 */       System.out.println("Usage: Tester <serverURL> <username> <password>");
/* 437 */       System.out.println("where:");
/* 438 */       System.out.println("<serverURL> is the full URL to the SOAP service");
/* 439 */       System.out.println("<username> is the name of the user to log in as");
/* 440 */       System.out.println("<password> is that user's password");
/* 441 */       System.out.println("NOTE: THIS COMMAND WILL DELETE E-MAIL!!!");
/*     */     }
/* 443 */     String serverURL = argv[0];
/* 444 */     System.out.println("connecting to " + serverURL + " as " + argv[1] + " with password " + argv[2]);
/*     */     
/*     */ 
/*     */     try
/*     */     {
/* 449 */       LmcPingRequest pr = new LmcPingRequest();
/* 450 */       LmcPingResponse pResp = (LmcPingResponse)pr.invoke(serverURL);
/*     */       
/*     */ 
/* 453 */       System.out.println("========= AUTHENTICATE ===========");
/* 454 */       LmcAuthRequest auth = new LmcAuthRequest();
/* 455 */       auth.setUsername(argv[1]);
/* 456 */       auth.setPassword(argv[2]);
/* 457 */       LmcAuthResponse authResp = (LmcAuthResponse)auth.invoke(serverURL);
/* 458 */       LmcSession session = authResp.getSession();
/*     */       
/*     */ 
/* 461 */       doGetDumpPrefs(session, serverURL);
/*     */       
/*     */ 
/* 464 */       System.out.println("======== GET TAGS =======");
/* 465 */       LmcGetTagRequest gtReq = new LmcGetTagRequest();
/* 466 */       gtReq.setSession(session);
/* 467 */       LmcGetTagResponse gtResp = (LmcGetTagResponse)gtReq.invoke(serverURL);
/*     */       
/*     */ 
/* 470 */       System.out.println("==== DUMP TAGS ======");
/* 471 */       LmcTag[] tags = gtResp.getTags();
/* 472 */       for (int t = 0; (tags != null) && (t < tags.length); t++) {
/* 473 */         System.out.println(tags[t]);
/*     */       }
/*     */       
/* 476 */       System.out.println("==== GET FOLDERS ======");
/* 477 */       LmcGetFolderRequest gfReq = new LmcGetFolderRequest();
/* 478 */       gfReq.setSession(session);
/* 479 */       LmcGetFolderResponse gfResp = (LmcGetFolderResponse)gfReq.invoke(serverURL);
/*     */       
/*     */ 
/* 482 */       System.out.println("====== DUMP FOLDERS ======");
/* 483 */       LmcFolder folder = gfResp.getRootFolder();
/* 484 */       recursiveDumpFolder(folder, 0);
/*     */       
/*     */ 
/* 487 */       System.out.println("==== SEARCH in:inbox ======");
/* 488 */       LmcSearchRequest sReq = new LmcSearchRequest();
/* 489 */       sReq.setOffset("0");
/* 490 */       sReq.setLimit("30");
/* 491 */       sReq.setQuery("in:inbox");
/* 492 */       sReq.setSession(session);
/* 493 */       sReq.setTypes(MailItem.Type.CONVERSATION.toString());
/* 494 */       LmcSearchResponse sResp = (LmcSearchResponse)sReq.invoke(serverURL);
/*     */       
/*     */ 
/* 497 */       System.out.println("====== DUMP SEARCH ======");
/* 498 */       System.out.println("offset=\"" + sResp.getOffset() + "\" more=\"" + sResp.getMore() + "\"");
/*     */       
/* 500 */       LmcConversation conv = null;
/* 501 */       LmcConversation firstConv = null;
/* 502 */       List cList = sResp.getResults();
/* 503 */       for (Iterator cit = cList.iterator(); cit.hasNext();) {
/* 504 */         conv = (LmcConversation)cit.next();
/* 505 */         if (firstConv == null)
/* 506 */           firstConv = conv;
/* 507 */         System.out.println(conv);
/*     */       }
/*     */       
/*     */ 
/*     */ 
/*     */ 
/* 513 */       getAndDumpContacts(session, serverURL);
/*     */       
/*     */ 
/*     */ 
/* 517 */       System.out.println("===== GET CONVERSATION =====");
/* 518 */       LmcGetConvRequest gconvReq = new LmcGetConvRequest();
/* 519 */       gconvReq.setConvToGet(firstConv.getID());
/* 520 */       gconvReq.setSession(session);
/*     */       
/*     */ 
/*     */ 
/*     */ 
/* 525 */       String[] msgDetail = { firstConv.getMessages()[0].getID() };
/* 526 */       gconvReq.setMsgsToGet(msgDetail);
/* 527 */       LmcGetConvResponse gconvResp = (LmcGetConvResponse)gconvReq.invoke(serverURL);
/*     */       
/*     */ 
/* 530 */       System.out.println("===== DUMP CONVERSATION ===== ");
/* 531 */       System.out.println(gconvResp.getConv());
/*     */       
/*     */ 
/* 534 */       System.out.println("===== GET MESSAGE ===== ");
/* 535 */       LmcGetMsgRequest gmReq = new LmcGetMsgRequest();
/* 536 */       gmReq.setRead("1");
/* 537 */       gmReq.setMsgToGet(msgDetail[0]);
/* 538 */       gmReq.setSession(session);
/* 539 */       LmcGetMsgResponse gmResp = (LmcGetMsgResponse)gmReq.invoke(serverURL);
/*     */       
/*     */ 
/* 542 */       System.out.println("===== DUMP MESSAGE ===== ");
/* 543 */       System.out.println(gmResp.getMsg());
/*     */       
/*     */ 
/*     */ 
/*     */ 
/* 548 */       System.out.println("===== SEND MESSAGE ===== ");
/* 549 */       LmcMessage lMsg = new LmcMessage();
/* 550 */       lMsg.setEmailAddresses(new LmcEmailAddress[] { gEa });
/* 551 */       lMsg.setSubject("msg from the test program");
/* 552 */       LmcMimePart smrMp = new LmcMimePart();
/* 553 */       smrMp.setContentType("text/plain");
/* 554 */       smrMp.setContent("there is some fresh coffee somewhere");
/* 555 */       lMsg.addMimePart(smrMp);
/* 556 */       LmcSendMsgRequest smr = new LmcSendMsgRequest();
/* 557 */       smr.setMsg(lMsg);
/* 558 */       smr.setSession(session);
/*     */       
/*     */ 
/* 561 */       String aid = smr.postAttachment("http://dogfood.example.zimbra.com/service/upload", session, new File("c:/temp/ops.txt"), ".example.zimbra.com", 5000);
/*     */       
/* 563 */       System.out.println("got back attachment id " + aid);
/* 564 */       lMsg.setAttachmentIDs(new String[] { aid });
/* 565 */       LmcSendMsgResponse smrResp = (LmcSendMsgResponse)smr.invoke(serverURL);
/*     */       
/*     */ 
/* 568 */       System.out.println("==== DUMP SEND MSG RESPONSE ====");
/* 569 */       System.out.println("Send successful, resulting ID " + smrResp.getID());
/*     */       
/* 571 */       doSearchReadDelete(session, serverURL);
/*     */       
/* 573 */       doSearchAndConvAction(session, serverURL);
/*     */       
/* 575 */       doCreateDeleteFolder(session, serverURL);
/*     */       
/*     */ 
/* 578 */       doCreateDeleteContact(session, serverURL);
/*     */       
/* 580 */       doCreateDeleteTag(session, serverURL);
/*     */       
/* 582 */       doModifyDumpPrefs(session, serverURL);
/*     */       
/* 584 */       doCreateGetDeleteNote(session, serverURL);
/*     */       
/* 586 */       doChangePassword(session, argv[1], argv[2], serverURL);
/*     */       
/* 588 */       doGetInfo(session, serverURL);
/*     */       
/* 590 */       doSearchGal(session, serverURL, "Kevin");
/* 591 */       doSearchGal(session, serverURL, "Satish");
/*     */       
/* 593 */       doSearchConv(session, serverURL);
/*     */       
/* 595 */       doBrowse(session, serverURL);
/*     */       
/* 597 */       doAddMsg(session, serverURL);
/*     */     }
/*     */     catch (SoapFaultException e)
/*     */     {
/* 601 */       e.printStackTrace();
/*     */     }
/*     */     catch (IOException e) {
/* 604 */       e.printStackTrace();
/*     */     } catch (LmcSoapClientException e) {
/* 606 */       e.printStackTrace();
/*     */     } catch (ServiceException e) {
/* 608 */       e.printStackTrace();
/*     */     }
/*     */   }
/*     */ }


/* Location:              /home/mint/zimbrastore.jar!/com/zimbra/cs/client/soap/Tester.class
 * Java compiler version: 7 (51.0)
 * JD-Core Version:       0.7.1
 */